<template>
	<mescroll-uni :ref="'mescrollRef'+tabIndex" @init="mescrollInit"   @down="downCallback" @up="upCallback" :up="upOption">
		<!-- 数据列表 -->
		<view class="u-padding-left-32 u-padding-right-32">
			<view class="u-margin-top-20" v-for="(item,index) in dataList" :key="index">
				<item-box padding="30">
					<view class="u-flex u-row-between u-font-24 u-padding-bottom-22 u-margin-bottom-24 u-border-bottom">
						<text>订单号：{{item.orderId}}</text>
						<!-- 体验本  有退还时间代表已退还  就显示已退还 -->
						<text class="text-color-txtTheme" v-if="!!item.experienceReturnTime">已退还</text>
						<text class="text-color-txtTheme" v-else>{{item.cartInfoStatus | statusName}}</text>
					</view>
					<view class="u-margin-bottom-20" v-for="(val,i) in item.productSmallDtos" :key="i"  @click="more(item)">
						<view class="u-flex u-row-left u-col-top">
							<item-image  :img="val.image" :width="180" :height="180" radius="10" />
							<view class=" u-flex-1 right-content">
								<view class="u-font-32 box-title  text-bold u-flex-1 u-line-1" style="width: 50vw;">{{val.name}}</view>
								<view class="u-font-24 text-4d4d4d u-flex-1 u-margin-top-16"  v-if="loginForm.userType=='issue'&&form.productType!=='ticket'">买家昵称：{{item.realName}}</view>
								<view v-if="item.ticketIds">
									<view class="u-margin-top-15 u-font-22 u-flex u-row-between">
										<text class="text-order-time">{{item.ticketIds[0] | formatId}}</text>
										<text class="text-color-txtTheme" @click.stop="copy(item.ticketIds[0])">复制</text>
									</view>
									<!-- <view v-if="item.ticketIds.length>1" class="u-margin-top-20 more-ticket" @click="more(item.id)">查看更多</view> -->
								</view>
								<view class="u-flex u-margin-top-6">
									<view class="u-flex-1" v-if="!!item.experienceProductId">
										<money :price="item.experiencePrice" color="#333333"></money>
									</view>
									<view class="u-flex-1" v-else>
										<money :price="val.price" color="#333333"></money>
									</view>
									<view class="text-color-9598a4 u-font-26 text-4d4d4d">x{{val.number}}</view>
								</view>
								<!-- 是体验本  并且有退还时间  说明是已退还的本了  只有退还时间 -->
								<view class="text-4d4d4d u-font-20 u-margin-top-10" v-if="!!item.experienceProductId && !!item.experienceReturnTime">退还时间：{{item.experienceReturnTime}}</view>
								<!-- 其余的只有下单时间 -->
								<view class="text-4d4d4d u-font-20 u-margin-top-10" v-else>下单时间：{{item.createTime}}</view>
								<!-- 体验本订单 如果是体验本 并且是已经付款了  就显示这部分   如果有体验天数字段 就显示-->
								<view class="u-font-20 text-color-txtTheme" v-if="!!item.experienceProductId">
									<view class="u-flex u-margin-top-10" v-if="item.cartInfoStatus!==0">
										<text>已付体验金：{{item.totalPrice}}</text>
										<!-- <money :price="item.totalPrice" color="#765CFE"></money> -->
									</view>
									<view class="u-flex" v-if="!!item.surplusExperienceDay">
										<text>剩余体验天数：{{item.surplusExperienceDay}}天</text>
									</view>
								</view>
							</view>
						</view>
					</view>
	
					<!-- 非定金购买的 不是体验本的订单  才显示实付款 -->
					<view class="u-flex u-row-right" v-if="!item.totalDeposit && !item.experienceProductId">
						<text class="u-font-30 content-desc-item">实付款：</text>
						<money :price="item.totalPrice" color="#765CFE"></money>
						<text class="u-font-22 text-order-666" v-if="form.productType!=='ticket'">(免运费)</text>
					</view>
					<!-- 体验本  显示商品金额 -->
					<view class="u-flex u-row-right" v-if="!item.totalDeposit && !!item.experienceProductId">
						<text class="u-font-30 content-desc-item">商品金额：</text>
						<money :price="item.experiencePrice" color="#765CFE"></money>
						<text class="u-font-22 text-order-666" v-if="form.productType!=='ticket'">(免运费)</text>
					</view>

					<!-- 非票务订单 定金购买的-->
					<view class="u-flex u-row-between u-font-26 text-color-9698A4 u-padding-top-12 u-padding-bottom-32" v-if="item.totalDeposit&&item.depositPaid &&form.productType!=='ticket'">
						<view class="u-flex">
							<text class="u-font-30 content-desc-item">已付定金：</text>
							<money :price="item.totalDeposit" color="#765CFE"></money>
						</view>
						<view class="u-flex">
							<text class="u-font-30 content-desc-item">实付款：</text>
							<money :price="item.totalPrice" color="#765CFE"></money>
						</view>
					</view>
					<!-- 票务订单 并且有定金的 -->
					<template v-if="item.totalDeposit>0 && form.productType=='ticket'">
						<!--  depositPaid是是否已经付了定金的意思  1已付  0未付     totaldeposit的是定金金额的意思  如果大于0 就代表是定金订单  不管他付没付定金-->
						<view v-if="item.depositPaid" class="u-flex u-row-right u-font-24 u-padding-top-12 u-padding-bottom-32" style="">
							<view class="u-flex day-color u-margin-right-30">
								<text>定金已支付：</text>
								<text>¥{{item.totalDeposit}}</text>
							</view>
							<view class="u-flex box-title text-bold">
								<text>尾款待支付：</text>
								<text>¥{{balance(item)}}</text>
							</view>
						</view>
						<view v-else class="u-flex u-row-right u-font-24 u-padding-top-12 u-padding-bottom-32">
							<view class="u-flex day-color u-margin-right-30">
								<text>尾款待支付</text>
								<text>¥{{balance(item)}}</text>
							</view>
							<view class="u-flex box-title  text-bold">
								<text>定金待支付</text>
								<text>¥{{item.totalDeposit}}</text>
							</view>
						</view>
					</template>

					<template v-if="form.productType!=='ticket'">
						<view class="btns u-text-right u-margin-bottom-18 u-flex u-row-right" v-if="loginForm.userType!='issue'">
							<!-- <template v-if="item.cartInfoStatus===0">
								待付款
								<template v-if="!item.totalDeposit">
									<view>
										<item-btn width="190" height="62" type="plain" @click="removeOrder(item,'取消')">
											<text class="content-desc-item u-font-24">取消订单</text>
										</item-btn>
									</view>
									<view class="u-margin-left-20">
										<item-btn width="190" height="62" @click="payOrder(item)">
											<text class="u-font-24">付款</text>
										</item-btn>
									</view>
								</template>
								<view class="">
									<item-btn width="190" height="62" @click="deposit(item)"  v-if="item.totalDeposit">
										<text class="u-font-24">确认收货</text>
									</item-btn>
								</view>
							</template> -->
							<template v-if="item.cartInfoStatus===0">
								<!-- 待付款 -->
								<view v-if="!item.depositPaid">
									<item-btn width="190" height="62" type="plain" @click="removeOrder(item,'取消')">
										<text class="content-desc-item u-font-24">取消订单</text>
									</item-btn>
								</view>
								<view class="u-margin-left-20" >
									<item-btn width="190" height="62" @click="payOrder(item)"  v-if="!item.totalDeposit">
										<text class="u-font-24">付款</text>
									</item-btn>
									<item-btn width="190" height="62" @click="deposit(item)"  v-if="item.totalDeposit">
										<text class="u-font-24">{{item.depositPaid ? '付尾款':'付定金'}}</text>
									</item-btn>
								</view>
							</template>
							<!-- 待发货 -->
							<text class="u-font-26 text-color-999" v-if="item.cartInfoStatus===1">等待商家发货</text>
							<!-- 待收货 -->
							<template v-if="item.cartInfoStatus===2"> 
								<view>
									<item-btn width="190" height="62" @click="longGoods(item)" type="plain">
										<text class="u-font-24 content-desc-item">延长收货</text>
									</item-btn>
								</view>
								<view class="u-margin-left-20">
									<item-btn width="190" height="62" @click="logistics(item)" type="plain">
										<text class="u-font-24 content-desc-item">查看物流</text>
									</item-btn>
								</view>
								<view class="u-margin-left-20">
									<item-btn width="190" height="62" @click="getGoods(item)">
										<text class="u-font-24">确认收货</text>
									</item-btn>
								</view>
							</template>
							<!-- 不是体验本的普通本 待评价 正常流程-->
							<template v-if="item.cartInfoStatus===3 && !item.experienceProductId">
								<!-- 待评价 -->
								<!-- item-btn width="190" height="62" @click="removeOrder(item)">
									<text class="u-font-24">删除订单</text>
								</item-btn> -->
									<view>
										<item-btn width="190" height="62" @click="afterSales(item,'applyAfterSale')" v-if="item.isAfterSale==0" type="plain">
											<text class="u-font-24 content-desc-item">申请售后</text>
										</item-btn>
									</view>
									<view class="u-margin-left-20">
										<item-btn width="190" height="62" @click="addCar(item)"  type="plain">
											<text class="u-font-24">再次购买</text>
										</item-btn>
									</view>
									<view class="u-margin-left-20">
										<item-btn width="190" height="62" @click="afterSales(item,'evaluate')">
											<text class="u-font-24">立即评价</text>
										</item-btn>
									</view>
							</template>
							<!-- 体验本 待评价-->
							<template v-if="item.cartInfoStatus===3 && !!item.experienceProductId">
								<!-- experiencePaymentStatus; // 1-可退回 可购买  2-只能购买  0不能退回不能购买-->
									<view v-if="item.experiencePaymentStatus==1">
										<item-btn width="190" height="62" @click="afterSales(item,'experienceProductReturn')" v-if="!item.experienceReturnTime" type="plain">
											<text class="u-font-24 content-desc-item">我要退还</text>
										</item-btn>
									</view>
									<view class="u-margin-left-20" v-if="item.experiencePaymentStatus==1 || item.experiencePaymentStatus==2">
										<item-btn width="190" height="62" @click="goPayExperienceProduct(item)"  type="plain">
											<text class="u-font-24">我要买本</text>
										</item-btn>
									</view>
									<view class="u-margin-left-20">
										<item-btn width="190" height="62" @click="afterSales(item,'evaluate')">
											<text class="u-font-24">立即评价</text>
										</item-btn>
									</view>
							</template>
							<!-- 不是体验本 已完成状态：申请售后 再次购买-->
							<template v-if="item.cartInfoStatus===4 && !item.experienceProductId">
								<view>
									<item-btn width="190" height="62" @click="afterSales(item,'applyAfterSale')" v-if="item.isAfterSale==0" type="plain">
										<text class="u-font-24 content-desc-item">申请售后</text>
									</item-btn>
								</view>
								<view class="u-margin-left-20">
									<item-btn width="190" height="62" @click="addCar(item)">
										<text class="u-font-24">再次购买</text>
									</item-btn>
								</view>
							</template>
							<!-- 体验本 已完成状态：我要退还 我要买本-->
							<template v-if="item.cartInfoStatus===4  && !!item.experienceProductId">
								<view v-if="item.experiencePaymentStatus==1">
									<item-btn width="190" height="62" @click="afterSales(item,'experienceProductReturn')" v-if="!item.experienceReturnTime" type="plain">
										<text class="u-font-24 content-desc-item">我要退还</text>
									</item-btn>
								</view>
								<view class="u-margin-left-20" v-if="item.experiencePaymentStatus==1 || item.experiencePaymentStatus==2">
									<item-btn width="190" height="62" @click="goPayExperienceProduct(item)">
										<text class="u-font-24">我要买本</text>
									</item-btn>
								</view>
							</template>
						</view>
						<!-- 发行身份看到订单列表 -->
						<view class="btns u-text-right u-margin-bottom-18 u-flex u-row-right" v-if="loginForm.userType=='issue'">
							<template v-if="item.cartInfoStatus===1">
								<!-- 待发货 -->
								<view>
									<item-btn width="190" height="62" @click="showAddress(item)" type="plain">
										<text class="u-font-24 content-desc-item">查看收货地址</text>
									</item-btn>
								</view>
								<view class="u-margin-left-20">
									<item-btn width="190" height="62" @click="showExpress(item)">
										<text class="u-font-24">发货</text>
									</item-btn>
								</view>
							</template>
							<view v-if="item.cartInfoStatus===2">
								<!-- 待收货 -->
								<item-btn width="190" height="62" @click="logistics(item)">
									<text class="u-font-24">查看物流</text>
								</item-btn>
							</view>
							<!-- 待评价 -->
							<view v-if="item.cartInfoStatus===3" class="u-font-26 text-color-999">等待买家评价</view>
						</view>
					</template>
					<!-- 票务订单单独处理  只有付款 取消订单流程 -->
					<view class="btns u-text-right  u-flex u-row-right" v-if="form.productType=='ticket'">
						<template v-if="item.cartInfoStatus===0">
							<!-- 待付款 -->
							<view v-if="!item.depositPaid">
								<item-btn width="190" height="62" type="plain" @click="removeOrder(item,'取消')">
									<text class="content-desc-item u-font-24">取消订单</text>
								</item-btn>
							</view>
							<view class="u-margin-left-20" >
								<item-btn width="190" height="62" @click="payOrder(item)"  v-if="!item.totalDeposit">
									<text class="u-font-24">付款</text>
								</item-btn>
								<item-btn width="190" height="62" @click="deposit(item)"  v-if="item.totalDeposit">
									<text class="u-font-24">{{item.depositPaid ? '付尾款':'付定金'}}</text>
								</item-btn>
							</view>
						</template>
						<view v-if="item.cartInfoStatus===4">
							<!-- 已完成 -->
							<item-btn width="190" height="62" @click="addCar(item)">
								<text class="u-font-24">再次购买</text>
							</item-btn>
						</view>
					</view>
					<!-- 待评价 和 已完成 状态可以删除订单  -->
					<view v-if="(loginForm.userType!='issue' || form.productType=='ticket') && [3,4].includes(item.cartInfoStatus) " class="u-position-relative">
						<!-- 如果是体验本  不可以退还也不可以购买时  才展示更多按钮 -->
						<template v-if="!!item.experienceProductId && item.experiencePaymentStatus==0">
							<view class="text-color-999 u-font-22" @click.stop="showItemModel(item,index)">更多</view>
						</template>
						<!-- 其他订单 如果不是体验本  待评价 和 已完成  直接显示更多按钮 -->
						<template v-if="!item.experienceProductId">
							<view class="text-color-999 u-font-22" @click.stop="showItemModel(item,index)">更多</view>
						</template>
						<view v-show="item.showModel">
							<view class="u-position-absolute arrow">
								<u-image src="https://larp-gbo.oss-cn-chengdu.aliyuncs.com/larp/common-light/up.png" width="30" height="30"></u-image>
							</view>
							<view class="u-position-absolute more-model">
								<view class="u-font-24 model-item" @click="removeOrder(item)">删除订单</view>
							</view>
						</view>
					</view>
				</item-box>
			</view>
		</view>
		<u-popup  v-model="show" mode="center" border-radius="14" width="85%" closeable :mask-close-able="false">
			<view class="u-padding-10 content-desc-item text-bold u-text-center u-border-bottom u-font-32">物流信息</view>
			<view>
				<view class="u-padding-20 ">
					<text class="u-font-28 text-order-time u-margin-top-20">订单号：{{checkObj.orderId}}</text>
					<!-- <view class="u-font-32 u-margin-bottom-10">{{['暂无物流信息','已揽件','运输中','已签收','问题件'][checkObj.State]}}</view> -->
				</view>
				<scroll-view scroll-y="true" class="scroll-view" v-if="checkObj.Traces&&checkObj.Traces.length">
					<view class="u-padding-32">
						<u-time-line>
							<u-time-line-item nodeTop="2" v-for="(item,index) in checkObj.Traces" bg-color="transparent" :key="index">
								<template slot="content">
									<view class="">
										<view class="u-order-desc">{{item.AcceptStation}}</view>
										<view class="u-margin-top-10">{{item.AcceptTime}}</view>
									</view>
								</template>
							</u-time-line-item>
						</u-time-line>
					</view>
				</scroll-view>
				<empty v-else :option="{tip:'暂无物流信息'}"></empty>
			</view>
		</u-popup>
		<u-popup  v-model="showAddressFlag" mode="center" border-radius="14" width="85%" closeable>
			<view class="u-padding-10 content-desc-item text-bold u-text-center u-border-bottom u-font-32">收货地址</view>
			<view class="u-padding-left-30 u-padding-right-30">
				<label-box label="收件人" labelSize="28" paddingTb="0" labelWidth="120">
					<text class="u-font-28 content-desc-item">{{checkObj.realName}}</text>
				</label-box>
				<label-box label="电话" labelSize="28" paddingTb="0" labelWidth="120">
					<text class="u-font-28 content-desc-item">{{checkObj.userPhone}}</text>
				</label-box>
				<label-box label="收货地址" labelSize="28" paddingTb="0" labelWidth="120">
					<text class="u-font-28 content-desc-item">{{checkObj.userAddress}}</text>
				</label-box>
			</view>
			<view class="u-flex u-row-center u-padding-30">
				<item-btn width="100%" height="88" @click="copyAddress(checkObj)">
					<text class="u-font-30">复制</text>
				</item-btn>
			</view>
		</u-popup>
		<!-- <u-mask :show="activeItemFlag" :zoom="false" :z-index="20" 
		:custom-style="{background:'rgba(0,0,0,0)'}"
		@click="hideModel"></u-mask> -->
	</mescroll-uni>
</template>

<script>
	import upCallback from '@/mixins/upCallbackMixin.js'
	import data from '@/data/index.js'
	import {customRequest,add,deleteIds,getDetail} from '@/api/crud.js'
	import loginMixins from '@/pagesA/login/login.js'
	import empty from '@/components/mescroll-uni/components/mescroll-empty.vue'
	import money from '@/components/money/money.vue'
	import {
		BigNumber
	} from "bignumber.js";
	export default {
		components: {
			empty,money
		},
		mixins: [upCallback,loginMixins], 
		props:{
			form:{
				type:Object,
				default:()=>({})
			},
			tabIndex:{
				type:Number,
				default:0
			}
		},
		data() {
			return {
				apiModule:'shopApi',
				apiType:'storeOrder',
				upOption:{
				},
				whiteStyle:{
					width:'162rpx',
					height:"50rpx",
					backgroundColor:'transparent',
					color:'white',
					fontSize:'22rpx',
					margin:'0 5rpx'
				},
				themeStyle:{
					width:'152rpx',
					height:"50rpx",
					backgroundColor:'transparent',
					color:'#765CFE',
					fontSize:'22rpx',
					margin:'0 5rpx'
				},
				dataList:[],
				show:false,
				checkObj:{},
				showAddressFlag:false,
				expressList:[],
				activeItemFlag:false,
				logisticsLoading:false
			}
		},
		created() {
			uni.$on('payMoney',()=>{
				uni.$on('payMoney',res=>{
					console.log(res)
					uni.hideLoading()
					res.uid==this.loginForm.uid&&this.navtoFlag(1)
					this.mescroll.resetUpScroll()
					// payMoney 付款成功后 更新 全部 待付款  已完成（如果是票务订单需要更新这个） 待发货（如果不是票务订单需要更新这个）
					this.resetUpTab('payMoney')
				})
			})
		},
		destroyed() {
			uni.$off('payMoney')
		},
		methods: {
			deposit(item){
				if(item.depositPaid){
					this.$u.route({
						url:"/pagesA/depositPage/depositPage",
						params:{
							orderId:item.orderId
						}
					})
					return false;
				}
				this.payOrder(item) //付定金
				
			},
			//取消和删除订单
			removeOrder(item,typeStr="删除"){
				this.$set(item,'showModel',false)
				this.activeItemFlag = null;
				this.activeItemIndex = -1;
				uni.showModal({
					cancelText:'取消',
					confirmText:'确定',
					title:'温馨提示',
					content:`确定${typeStr}该订单？`,
					success: ({confirm}) => {
						confirm&&deleteIds('',this.apiType,this.apiModule,item.id).then(res=>{
							this.$u.toast('操作成功啦')
							this.mescroll.resetUpScroll() // 再刷新列表数据
							//remove 删除或者是取消订单 更新 全部 待付款（取消订单） 待评价（票务订单没有待评价-删除订单） 已完成（删除订单）
							this.resetUpTab('remove')
						})
					}
				})
			},
			ticketIds(item){
				return item.split(',')
			},
			//复制内容
			copy(val){
				uni.setClipboardData({
					data:val,
					success: () => {
						this.$u.toast('复制成功')
					},
					fail: () => {
						this.$u.toast('复制失败')
					}
				})
			},
			//再次购买
			addCar(item){
				const type = item.totalDeposit&&item.depositPaid ? 'groupBuy':this.form.productType;
				const cartInfoList = item.productSmallDtos.map(val=>({
				productId:val.id,
				mallProductId:item.mallProductId,
				productNum:1}))
				add({cartInfoList},'storeOrder',this.apiModule,'createTemp').then(res=>{
					this.$u.route({
						url:"/pagesA/settleAccounts/settleAccounts",
						params:{
							orderId:res,type
						}
					})
				})
			},
			//直接购买体验本对应的剧本
			async goPayExperienceProduct(item) {
				uni.showLoading({
					mask:true,
					title:'支付中...'
				})
				try{
					const code = await this.getLoginCode();
					let codeData = {code,payType:'weixin',platformType:'manage'}
					const data = await customRequest(codeData,this.apiType,this.apiModule,'cartInfoPayMoney/'+item.cartInfoOrderId,'post')
					if(data.paymentStatus==='success'){
						this.navtoFlag(1)
						this.mescroll.resetUpScroll() // 再刷新列表数据
						return false;
					}
					uni.requestPayment({ //微信支付
						provider: 'wxpay',...data,
						success:res=> {
							this.mescroll.resetUpScroll() // 再刷新列表数据
						},
						fail:({errMsg})=> {
							errMsg==='requestPayment:fail cancel' ? this.$u.toast('已取消支付') : this.navtoFlag(0)
						},
						complete:()=>{
							uni.hideLoading()
						}
					});
				}catch(e){
					uni.hideLoading()
					//TODO handle the exception
				}
			},
			navtoFlag(flag) {
				const title = flag == 1 ? '支付成功' : '支付失败';
				this.$u.toast(title);
				this.$u.route({
					type: 'redirectTo',
					url: '/pagesA/success/success',
					params: {
						flag,
						title,
						type: this.option.type
					}
				});
			},
			//售后和评价
			afterSales(item,type){
				this.$u.route({
					params:{type,id:item.id,cartInfoId:item.cartInfoId,orderId:item.orderId,experienceProductId:item.experienceProductId},
					url:'/pagesA/userSubmit/userSubmit'
				})
			},
			//确认收货
			getGoods(item){
				customRequest('',this.apiType,this.apiModule,'receivingGoods/'+item.cartInfoId,'post').then(res=>{
					this.$u.toast('收货成功')
					this.mescroll.resetUpScroll() // 再刷新列表数据
					// receivingGoods 确认收货 更新 全部 待评价（不是票务订单）
					this.resetUpTab('receivingGoods')
				})
			},
			//查看物流
			logistics(item){
				if(this.logisticsLoading){
					this.$u.toast("点那么快干啥？")
					return false;
				}
				this.logisticsLoading = true;
				getDetail({cartInfoId:item.cartInfoId},this.apiType,this.apiModule,'express').then(res=>{
					this.show = true
					this.checkObj = {...item,...res};
				}).finally(()=>{
					this.logisticsLoading = false;
				})
			},
			//延长收货
			longGoods(item){
				customRequest('',this.apiType,this.apiModule,'receiptExtend/'+item.id,'post').then(res=>{
					this.$u.toast('延长成功')
					this.mescroll.resetUpScroll() // 再刷新列表数据 
					//延长收货其实只调用了接口 其实后台并没有做什么处理
				})
			},
			navtoFlag(flag){
				const title = flag==1?'支付成功':'支付失败';
				this.$u.toast(title)
			},
			//付款
			async payOrder(item){
				uni.showLoading({
					mask:true,
					title:'支付中...'
				})
				try{
					const code = await this.getLoginCode();
					let codeData = {code,payType:'weixin',platformType:'manage'}
					const data = await customRequest(codeData,this.apiType,this.apiModule,'payMoney/'+item.orderId,'post')
					if(data.paymentStatus==='success'){
						this.navtoFlag(1)
						this.mescroll.resetUpScroll() // 再刷新列表数据
						return false;
					}
					uni.requestPayment({ //微信支付
						provider: 'wxpay',...data,
						success:res=> {
							this.mescroll.resetUpScroll() // 再刷新列表数据
						},
						fail:({errMsg})=> {
							errMsg==='requestPayment:fail cancel' ? this.$u.toast('已取消支付') : this.navtoFlag(0)
						},
						complete:()=>{
							//uni.hideLoading()
						}
					});
				}catch(e){
					uni.hideLoading()
					//TODO handle the exception
				}
			},
			//点击查看更多
			more(item){
				if(this.form.productType!=='ticket') return false;
				if(item.ticketIds&&item.ticketIds.length){
					this.$u.route({
						url:"/pagesA/moreTicket/moreTicket",
						params:{id:item.id}
					})
				}
			},
			showAddress(item){
				this.checkObj = {
					userAddress:item.userAddress,
					userPhone:item.userPhone,
					realName:item.realName
				};
				this.showAddressFlag=true
			},
			//复制收货地址
			copyAddress(item){
				uni.setClipboardData({
					data: `收货人: ${item.realName}
					收货电话: ${item.userPhone}
					收货地址: ${item.userAddress}`
				});
			},
			//显示发货弹框
			showExpress(item){
				this.$u.route({
					params:{
						cartInfoId:item.cartInfoId
					},
					url:'/pagesA/express/express'
				})
			},
			//显示删除订单的弹框
			showItemModel(item,index){
				this.$set(item,'showModel',!item.showModel)
				this.activeItemFlag = item.showModel;
				this.activeItemIndex = this.activeItemIndex === index ? -1 : index;
			},
			// 关闭遮罩并且重置属性
			hideModel(){
				this.activeItemFlag = false;
				this.$set(this.dataList[this.activeItemIndex],'showModel',false)
				this.activeItemIndex = -1
			},
			//尾款金额
			balance(item){
				const balance = BigNumber(item.totalPrice).minus(item.totalDeposit)
				return balance.toNumber()
			},
			//根据类型判断是否应该更新相关tab
			resetUpTab(type){
				let tabIndex = []
				switch (type){
					// payMoney 付款成功后 更新 全部  已完成（如果是票务订单需要更新这个） 待发货（如果不是票务订单需要更新这个）
					case 'payMoney':
						const index = this.form.productType==='ticket' ? 4 : 1
						tabIndex.push(index) // 如果是票务订单更新已完成 如果是买本订单更新待发货
						break;
					//remove 删除或者是取消订单 更新 全部 待付款（取消订单） 待评价（票务订单没有待评价-删除订单） 已完成（删除订单）
					case 'remove':
						tabIndex.push(0)
						const orderStatus = this.form.productType==='ticket' ? -1 : 3
						if(orderStatus>-1) tabIndex.push(orderStatus) // 如果是票务订单不需要更新待评价
						tabIndex.push(4)
						tabIndex = tabIndex.filter(val=>val!=this.form.orderStatus) // 过滤掉当前tab
						break;
					// receivingGoods 确认收货 更新 全部 待评价（不是票务订单）
					case 'receivingGoods':
						tabIndex.push(3) //待评价
						break;
				}
				this.$emit('changeTab',tabIndex)
			}
		},
		filters:{
			statusName(val){
				const tabs = data.orderList;
				const item = tabs.find(item=>item.value===val) || {};
				return item.name
			},
			formatId(val){
				if(val){
					const flag = val.indexOf('F')>-1;
					return `${flag ? '发行票':'店家票'}: ${val}`
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.right-content{
		flex-direction: column;
		display: flex;
		min-height: 166rpx;
		margin-left: 24rpx;
	}
	.scroll-view{
		height: 70vh;
		padding-bottom: 20rpx;
	}
	.more-ticket{
		border-radius: 50rpx;
		text-align: center;
		line-height: 60rpx;
		color: white;
		background-color: #765CFE;
		font-size: 20rpx;
	}
	.arrow{
		// width: 20rpx;
		// height: 20rpx;
		top: 20rpx;
		left: 15rpx;
		// transform: rotate(45deg);
		z-index: 25;
		// box-shadow: -6rpx -3rpx 8rpx 0 rgba(0, 0, 0, 0.1);
	}
	.more-model{
		border-radius: 16rpx;
		top: 45rpx;
		left: -20rpx;
		z-index: 24;
		box-shadow: 6rpx 0 12rpx 0 rgba(0, 0, 0, 0.1);
		background-color: var(--background-white);
		.model-item{
			padding: 17rpx 24rpx;
		}
	}
	.dark{
		
	}
	.light{
		.text-4d4d4d{
			color: #4d4d4d;
		}
		.text-color-999{
			color: #999;
		}
		// .arrow{
		// 	background-color: white;
		// }
		.more-model{
			// background-color: white;
		}
	}
	.content-desc-item{
		line-height: 70rpx;
	}
</style>
